home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
351-375
/
disk_370
/
sksh
/
reference.doc
< prev
next >
Wrap
Text File
|
1992-05-06
|
141KB
|
7,195 lines
Reference Manual
SKsh
A ksh-like Shell for the Amiga
Version 1.5
(Copyright) 1989, 1990
Steve Koren
July 20, 1990
Table of Contents
Introduction......................................4
!, !!.............................................5
_ANSI.............................................6
_DIR_.............................................7
_FILE_............................................7
_EXEC_............................................7
alias.............................................8
aliases...........................................9
AREXX_PORT........................................10
argcount..........................................11
SKSHINIT..........................................12
sksh..............................................13
basename..........................................14
break.............................................15
builtins..........................................16
case/esac.........................................17
cat...............................................18
cd................................................19
chmod.............................................20
clear, cls........................................21
CLINUM............................................22
CMDNUM............................................23
COLUMNS...........................................24
continue..........................................27
ctpri.............................................28
date..............................................29
dec...............................................30
dir...............................................31
dirname...........................................32
dwclist...........................................33
echo..............................................35
eval..............................................36
exit..............................................37
export............................................38
false.............................................41
for/do/done.......................................42
force.............................................43
function..........................................44
functions.........................................45
getenv............................................46
history...........................................47
HISTSIZE..........................................48
HOME..............................................49
IFS...............................................51
inc...............................................52
info..............................................53
LINES.............................................55
ll................................................56
LLMIN.............................................57
local.............................................58
LOGOUT............................................59
SKsh Amiga Shell Page 2 Reference Manual
ls................................................60
match.............................................62
MAXDIST...........................................63
mem...............................................64
mkdir.............................................65
mv................................................66
OLDPWD............................................67
options...........................................68
PATH..............................................71
path..............................................72
PNPC..............................................73
preparse..........................................74
printf............................................75
ps................................................76
PS1...............................................77
PS2...............................................78
PWD...............................................79
pwd...............................................80
quit..............................................81
read..............................................82
resident..........................................83
return............................................84
rm................................................85
rmdir.............................................86
ROOT..............................................87
set...............................................88
setmap............................................89
SHELL.............................................92
shift.............................................93
SIZE..............................................94
sleep.............................................95
source............................................96
stack.............................................97
SYSNAME...........................................98
time..............................................99
touch.............................................100
true..............................................101
unalias...........................................102
unfunc............................................103
unset.............................................104
variables.........................................105
version...........................................106
whence............................................107
which.............................................108
while/do/done.....................................109
SKsh Amiga Shell Page 3 Reference Manual
Introduction
This reference manual describes each SKsh command, variable,
alias, or function in a concise manner. Each page contains
the following information:
Name: The name of the command, alias, etc.
Type: Variable, Alias, Function, Builtin, or Keyword.
Default: The default value for variables, or definition for
aliases.
Usage: Command syntax
Range: Legal values for variables or parameters
About: Text describing the command, variable, etc.
Example: A brief example usage.
See Also: Other related commands, variables, etc.
When reading the command syntax, anything in square brackets
is optional. Anything followed by three dots can be re-
peated any number of times. A vertical bar is used to sepa-
rate option where one or the other, but not both, can be
used.
In general, options to commands are preceded by a dash ('-
'). The dash character passed alone tells a command to stop
reading options. This can be useful to pass a dash as a
parameter. For example,
echo - -
would print a single dash. Also, 'command -a -b' is equiva-
lent to 'command -ab'.
In version 1.4 and later of SKsh, the documentation for ex-
ternal binary commands has been moved to the ExtCmds.doc
file.
SKsh Amiga Shell Page 4 Reference Manual
_________________________________________________________________
Name: !, !!
Type: Alias
Default: history -e
history -e -1
Usage: ! [ pattern | abs_num | rel_num ]
!!
Range: n/a
About: These two aliases provide an easy way to use the
history -e command. !! will execute the previous
command from the history list by executing history
-e -1. ! will execute a specified command from
the history list. This command can either specify
an absolute number, a relative offset from the
most recent command (the offset should be nega-
tive), or a partial line or pattern to search for.
If a search pattern is given, it should be en-
closed in quotes so that SKsh does not attempt
file name generation on the wildcard pattern.
Example: ! cc
See Also: history
_________________________________________________________________
SKsh Amiga Shell Page 5 Reference Manual
_________________________________________________________________
Name: _ANSI_BS
_ANSI_BE
_ANSI_IS
_ANSI_IE
_ANSI_US
_ANSI_UE
_ANSI_P1
_ANSI_P2
_ANSI_P3
_ANSI_CLEAR
Type: Variable
Default: "^[[1m" (bold-start)
"^[[m" (bold-end)
"^[[3m" (italic-start)
"^[[m" (italic-end)
"^[[4m" (underline-start)
"^[[m" (underline-end)
"^[[0;31;40m" (pen-1)
"^[[0;32;40m" (pen-2)
"^[[0;33;40m" (pen-3)
"^[[H^[[2J" (clear screen)
Usage: $_ANSI_??
Range: n/a
About: These variables are set by SKsh to valid ANSI es-
cape sequences which control the Amiga console
device. They can be used in echo statements or
prompts.
Since these variables, when output, affect the
console device, they are not normally displayed by
the set command.
Example: echo $_ANSI_CLEAR # clear the screen
See Also: echo
_________________________________________________________________
SKsh Amiga Shell Page 6 Reference Manual
_________________________________________________________________
Name: _DIR_S
_DIR_E
_FILE_S
_FILE_E
_EXEC_S
_EXEC_E
Type: Variable
Default: "$_ANSI_P3" (dir-start)
"$_ANSI_P1" (dir-end)
NULL (file-start)
NULL (file-end)
NULL (exec-start)
NULL (exec-end)
Usage:
Range: n/a
About: These variables control the display format of the
'ls' command when the '-F' option is set (as it is
by default when the 'dir' or 'll' commands are
used). Before printing each file name (whether in
a short or long format listing), SKsh will examine
the file type. If the it is a directory, the con-
tents of the _DIR_S variable is printed. If it is
a file, the contents of _FILE_S is printed. If
the 'e' bit is set, _EXEC_S is printed. (Because
of this, it is possible to print more than one of
the above variables if the name is both a file and
has its 'e' bit set).
In a similar manner, the contents of the appropri-
ate _FILE_E, _DIR_E, and _EXEC_E variables is
printed after the file name. This allows the for-
mat of the directory listing to be customized.
These variables are only output when the '-F' op-
tion is used. Also, their contents is printed
verbatim; it is not expanded as with 'PS1'. Thus,
any variables should be expanded when these vari-
ables are set, as in the example below.
Example: _FILE_S="$_ANSI_US" # underline file names
_FILE_E="$_ANSI_UE"
See Also: ls, dir, ll
_________________________________________________________________
SKsh Amiga Shell Page 7 Reference Manual
_________________________________________________________________
Name: alias
Type: Builtin
Default: n/a
Usage: alias [ pattern | string [ '=' ] string ]
Range: n/a
About: The alias builtin command (not to be confused with
'aliases', which is itself an alias) is used to
set and list aliases. If given no parameters, it
simply acts as a 'set -a' command. If given one
parameter, which is a pattern, all aliases match-
ing that pattern are printed. If given two param-
eters (or there where the second is a '='), the
first string becomes an alias with the second
string as its definition.
Aliases are expanded when used as a command. Any
arguments are appended to the text of the aliases
and the resulting string is executed.
Unlike ksh and sh, there can be spaces surrounding
the '=' sign, which is itself optional.
Example: alias foo='echo "This is the foo alias"'
See Also: set, alias, unalias
_________________________________________________________________
SKsh Amiga Shell Page 8 Reference Manual
_________________________________________________________________
Name: aliases
Type: Alias
Default: set -a
Usage: aliases [-s] [pattern]
Range: n/a
About: This alias lists defined aliases. The pattern
uses normal wildcards, but must be quoted to avoid
being interpreted by the filename expansion
mechanism. If the pattern is omitted, all aliases
in the current context are listed except those be-
ginning with an underscore (hidden aliases).
Only aliases for the current context are listed,
so this command may have a different effect inside
of a subshell or function than when typed
manually.
Example: aliases -s '[a-h]*'
See Also: set, alias
_________________________________________________________________
SKsh Amiga Shell Page 9 Reference Manual
_________________________________________________________________
Name: AREXX_PORT
Type: Variable
Default: SKSH or SKSH_$CLINUM
unset if no ARexx port available
Usage: $AREXX_PORT
Range: n/a
About: This variable contains the name of the ARexx port
opened by SKsh open invocation. The variable will
be unset if SKsh did not open an ARexx port
(either because it was told not to, or it could
not because ARexx was not installed).
Example: if [ -z "$AREXX_PORT" ]
then
echo "This SKsh does not have an ARexx port"
else
echo "The ARexx port name is $AREXX_PORT"
fi
See Also: sksh
UserMan.doc:
Advanced Topics: Using SKsh with ARexx
_________________________________________________________________
SKsh Amiga Shell Page 10 Reference Manual
_________________________________________________________________
Name: argcount
Type: Builtin
Default: n/a
Usage: argcount [ parameter ... ]
Range: n/a
About: argcount simply prints a count of its arguments.
Example: argcount should 'print two'
See Also:
_________________________________________________________________
SKsh Amiga Shell Page 11 Reference Manual
_________________________________________________________________
Name: SKSHINIT
Type: Variable
Default: "sksh:.skshrc"
Usage: $SKSHINIT
Range: n/a
About: This variable is set in the .skshinit file to the
name of a user modifiable configuration file.
Normally this is "s:.skshrc". The user configura-
tion file is sourced (not executed!) for interac-
tive SKsh sessions.
The s:.skshrc file is provided for user
modification. Users should not modify
s:.skshinit. If you wish to change something that
is defined in s:.skshinit, simply redefine it in
s:.skshrc. s:.skshrc is sourced after
s:.skshinit.
Your s:.skshrc file may optionally source other
files.
In SKsh 1.5 and later, the preparsed form of this
file will be executed if it exists instead of the
ascii form.
Example:
See Also: sksh, source, preparse
_________________________________________________________________
SKsh Amiga Shell Page 12 Reference Manual
_________________________________________________________________
Name: sksh
Type: External Command
Default: n/a
Usage: sksh [ -a | -p portname ] [ -c string | fspec... ]
Range: n/a
About: This is, of course, the main SKsh binary. If in-
voked with no parameters, an interactive SKsh ses-
sion is started. If invoked with the '-c' option
followed by a string, the string is executed by
SKsh as if it had been typed, and SKsh exits when
the operation is complete. If the string contains
spaces, it must be surrounded by quotes (although
this depends on the invoking shell or environ-
ment). If invoked with filespec arguments, each
file in turn is executed (not sourced). SKsh then
exits when finished executing all the files.
If SKsh is invoked non-interactively, it will
still read the .skshinit file, but not the .skshrc
file. This allows you to have output statements
in the .skshrc file without having this output ap-
pear when non-interacrive scripts are run. If you
really want to run the .skshrc file first, use:
sksh s:.skshrc my_file.sksh
If SKsh is given the "-a" flag upon invocation, it
attempts to open an ARexx port if ARexx is indeed
installed on the system. The default port name is
"SKSH" (all caps). If this port is taken (perhaps
by another invocation of SKsh), SKsh appends an
underscore and the cli number of this process (for
example, "SKSH_5"), and tries again. If it still
cannot open the port, it gives up.
If the "-p" flag is given followed by a port name,
SKsh will attempts to use the following argument
as a portname when opening ARexx.
Example: sksh -c "expr 21 * 2"
See Also: source, AREXX_PORT
_________________________________________________________________
SKsh Amiga Shell Page 13 Reference Manual
_________________________________________________________________
Name: basename
Type: Builtin
Default: n/a
Usage: basename [ fspec ... ]
Range: n/a
About: basename prints the "base" name of a given path.
For example, the basename of sys:System/Format is
simply Format. Note that the basename may be a
directory and not a file; for example, the
basename of sys:usr/bin is bin, even though bin is
a directory. If basename is passed more than one
parameter, it prints the basename of each param-
eter in turn.
Example: basename sys:usr/bin/wc
See Also: dirname, extname
_________________________________________________________________
SKsh Amiga Shell Page 14 Reference Manual
_________________________________________________________________
Name: break
Type: Builtin
Default: n/a
Usage: break [ num ]
Range: n/a
About: break exits gracefully from an enclosing for or
while loop. If a numeric argument is given, it
breaks from that many enclosing levels of for or
while.
Example: for a in a b c d e f
do
echo $a
if [ "$a" = "c" ] then break; fi
done
See Also: continue
_________________________________________________________________
SKsh Amiga Shell Page 15 Reference Manual
_________________________________________________________________
Name: builtins
Type: Alias
Default: set -b
Usage: builtins [ -s ] [ pattern ]
Range: n/a
About: This aliases lists SKsh builtin commands. The
pattern uses normal wildcards, but must be quoted
to avoid being interpreted by the filename expan-
sion mechanism. If the pattern is omitted, all
builtins are listed except those beginning with an
underscore character (hidden builtins). There are
currently no hidden builtins.
Example: builtins -s '[a-h]*'
See Also: set
_________________________________________________________________
SKsh Amiga Shell Page 16 Reference Manual
_________________________________________________________________
Name: case/esac
Type: Keywords
Default: n/a
Usage: case param in { pattern ) stmt_list ;; } ... esac
Range: n/a
About: If the supplied parameter matches any of the
(wildcard) patterns, then the statement list for
that pattern is executed. A close-paren ( ")" )
must follow the wildcard pattern, and a double
semicolon must terminate the statement list. The
case statement must be terminated by a matching
esac keyword.
Example: case "$foo" in
bar) echo "Matched bar";
echo "testing..." ;;
n*t) echo "Matched n*t";;
a??c) echo "Matched a??c";;
esac
See Also:
_________________________________________________________________
SKsh Amiga Shell Page 17 Reference Manual
_________________________________________________________________
Name: cat
Type: Builtin
Default: n/a
Usage: cat [ fspec ... ]
Range: n/a
About: cat prints the contents of each file passed to it
on the command line, or the standard input if no
files are passed. The contents of each file are
concatenated, and are not separated by blank
lines.
In SKsh 1.5 and later, there are two forms of the
cat command, a builtin and an external binary.
The external binary is described in the
ExtCmds.doc file. It can be made the default; see
the documentation there for details.
In SKsh, the builtin cat cannot be used to trans-
fer binary files, only ASCII data. Also, the se-
quence:
cat my_file.txt > my_file1.txt
can be faster accomplished with the cp command or
the external cat command.
Example: cat my_file.txt
See Also: cp
The cat entry in the ExtCmds.doc file
_________________________________________________________________
SKsh Amiga Shell Page 18 Reference Manual
_________________________________________________________________
Name: cd
Type: Builtin
Default: n/a
Usage: cd [ -p | dirname ]
Range: n/a
About: cd changes the current working directory to
dirname, or to the previous directory (the con-
tents of the OLDPWD variable) if the -p flag is
set. If no parameters are passed, cd moves to the
directory indicated by the HOME variable. This is
convenient when you are doing most of your work in
one place, and wish to return there easily. Under
AmigaDos, the HOME variable can be changed very
easily with:
HOME=.
That is, you do not have to worry about certain
files being in the HOME directory as you do in a
multi-user operating system such as UNIX.
Example: cd -p # go back to old directory
See Also: PWD, pwd, OLDDIR
_________________________________________________________________
SKsh Amiga Shell Page 19 Reference Manual
_________________________________________________________________
Name: chmod
Type: Builtin
Default: n/a
Usage: chmod flags | +flags | -flags [ file ... ]
Range: flags : "hsparewd"
About: chmod changes the file protection bits on the
named files. Flags can be one or more of the fol-
lowing letters: "hsparewd". If the flags param-
eter is given directly with no leading '+' or '-',
the permissions for all the named files are set to
that value. A leading '+' causes the indicated
permissions bits to be set without changing the
others, and a leading '-' causes them to be reset.
In addition, a 'x' may be used in place of the 'e'
flag.
Example: chmod -a *.c # reset archive bit on all .c files
See Also: ls
_________________________________________________________________
SKsh Amiga Shell Page 20 Reference Manual
_________________________________________________________________
Name: clear, cls
Type: Alias
Default: echo -n $_ANSI_CLEAR
Usage: clear
Range: n/a
About: These aliases both clear the screen by echoing
$_ANSI_CLEAR.
Example: clear
See Also: _ANSI_CLEAR
_________________________________________________________________
SKsh Amiga Shell Page 21 Reference Manual
_________________________________________________________________
Name: CLINUM
Type: Variable
Default: n/a
Usage: $CLINUM
Range: 1 to maximum process number limit
About: This variable is set to the CLI process number of
SKsh when it is started.
Example: echo "Process # = $CLINUM"
See Also:
_________________________________________________________________
SKsh Amiga Shell Page 22 Reference Manual
_________________________________________________________________
Name: CMDNUM
Type: Variable
Default: n/a
Usage: $CMDNUM
Range: 1 to 16 million
About: Each time SKsh inputs a line from the keyboard,
this variable is incremented.
Example: echo "$CMDNUM lines have been entered so far."
See Also: history
_________________________________________________________________
SKsh Amiga Shell Page 23 Reference Manual
_________________________________________________________________
Name: COLUMNS
Type: Variable
Default: 72
Usage: $COLUMNS
Range: 15 to 130
About: This variable is one of several responsible for
controlling the actions of SKsh line editing and
display output. If line editing is enabled, and
the cursor moves beyond the column indicated by
this variable, SKsh slides the line to the left by
12 characters. SKsh also uses this variable to
truncate the output of certain internal SKsh com-
mands (such as History). This creates a cleaner
display.
This variable is normally set automatically by
SKsh when the window is resized, although this be-
havior can be disabled with the options command.
Example: COLUMNS=78
See Also: PNPC, LINES, options
_________________________________________________________________
SKsh Amiga Shell Page 24 Reference Manual
_________________________________________________________________
Name: complist
Type: Builtin
Default: -l option
Usage: complist [ -adel ] [ names ... ]
Range: n/a
About: The complist command provides a method to extend
the command line filename completion mechanism.
It only functions if SKsh command line editing is
enabled. SKsh maintains an internal completion
list of user defined strings. When <tab> or
<esc><esc> are used to complete a string, the in-
ternal completion list is consulted before comple-
tion is attempted on files. If a match is found
in the internal completion list (even if it is but
a partial match), it is used. If not, then
filename completion proceeds as normal. An option
is provided to turn on or off this behaviour (see
the options command for details).
-a Add the supplied arguments to the completion
list. The old contents of the list are left
in place.
-d Delete the supplied arguments from the
completion list.
-e Empty the completion list.
-l List the contents of the completion list, one
name per line. If no command line switches
are given, this is the default.
Hints: The completion list can, among other things, be
used to:
* Maintain a user defined list of strings to
contain, for example, device or program names
(such as "graphics:" or "calculator") which
are commonly typed.
* Contain programs names which are found in the
search path.
* Buffer the contents of the current directory
so that subsequent successful completions do
not have to read the directory. This makes
filename completion usable on a floppy based
SKsh Amiga Shell Page 25 Reference Manual
system or on a hard disk when a directory
contains a large number of files. A shell
function is supplied in the Stuff.sksh file
which adds the files in the current directory
to the completion list.
* Perform completion on files stored inside of
a zoo archive. A function supplied in the
Stuff.sksh file facilitates this process. It
could also, with a little work, be extended
to handle other archive types.
Example: complist -e # empty the completion list
# now add these names...
complist -a graphics: my_program foo
See Also: zget, cget (from Stuff.sksh)
options (+C)
_________________________________________________________________
SKsh Amiga Shell Page 26 Reference Manual
_________________________________________________________________
Name: continue
Type: Builtin
Default: n/a
Usage: continue [ num ]
Range: n/a
About: continue resumes execution with the next iteration
of the surrounding loop, or the nth subsequent it-
eration if given a numeric argument.
Example: for a in a b c d e f
do
echo $a
if [ "$a" = "c" ] then continue; fi
echo "This is not echoed when \$a = c"
done
See Also: break
_________________________________________________________________
SKsh Amiga Shell Page 27 Reference Manual
_________________________________________________________________
Name: ctpri
Type: Alias
Default: ChangeTaskPri
Usage: ctpri
ctpri num
Range: -31 <= num <= 31
About: This alias is provided as a shorter alternative to
the AmigaDos ChangeTaskpri command. Its use is
identical.
Example: ctpri 1
See Also: stack
_________________________________________________________________
SKsh Amiga Shell Page 28 Reference Manual
_________________________________________________________________
Name: date
Type: Builtin
Default: n/a
Usage: date [-aDmdty]
Range: n/a
About: Date prints the current date as a 24 character
string:
DDD mmm dd hh:mm:ss yyyy
Date with the -a (all) option is identical to date
with no parameters, (which prints the date as above).
Date -D prints a three character representation of
the day of the week. Date -m prints a three charac-
ter representation of the month. Date -d prints the
day number as two digits. Date -t prints the time
string, and date -y prints the year as four digits.
Example: date -y # find the year
See Also: time
_________________________________________________________________
SKsh Amiga Shell Page 29 Reference Manual
_________________________________________________________________
Name: dec
Type: Builtin
Default: n/a
Usage: dec var [ count ]
Range: n/a
About: dec decrements the contents of the variable by
count, or 1 if count is not given. It is equiva-
lent to, but faster than, 'var=$(expr $var -
$count)'
Example: dec my_var 3
See Also: inc
_________________________________________________________________
SKsh Amiga Shell Page 30 Reference Manual
_________________________________________________________________
Name: dir
Type: Alias
Default: ls -bF
Usage: dir [ file | dir ] ...
Range: n/a
About: dir prints a short format directory listing, with
only the basename of each file printed. Note that
the 'F' option to 'ls' is set.
Example: dir s:
See Also: ls, ll
_________________________________________________________________
SKsh Amiga Shell Page 31 Reference Manual
_________________________________________________________________
Name: dirname
Type: Builtin
Default: n/a
Usage: complist [ -adel ] [ names ... ]
Range: n/a
About: dirname prints the "directory" name of a given
path. For example, the dirname of sys:System/For-
mat is simply sys:System. If dirname is passed
more than one parameter, it prints the dirname of
each parameter in turn.
Example: dirname sys:usr/bin/wc
See Also: basename, extname
_________________________________________________________________
SKsh Amiga Shell Page 32 Reference Manual
_________________________________________________________________
Name: dwclist
Type: Builtin
Default: -l option
Usage: dwclist [ -adel ] [ names ... ]
Range: n/a
About: The dwclist (disabled wildcard list) command pro-
vides the ability so selectively disable wildcard
expansion for individual commands. When expanding
wildcards, SKsh first checks the command name for
inclusion in the dwclist. If found, SKsh will not
expand parameters which contain wildcards, but
rather, will pass these wildcards to the command
directly.
The dwclist is very useful for external programs
which perform their own wildcard expansion. By
putting the command in the dwclist, SKsh will let
that command perform its own wildcard expansion,
thus circumventing the 255 character command line
limit in AmigaDos 1.3.
An option is provided to turn on or off this be-
haviour (see the options command for details).
The default is to ignore the dwclist.
The following arguments, similar to those for the
complist command, are accepted:
-a Add the supplied arguments to the dwclist.
The old contents of the list are left in
place.
-d Delete the supplied arguments from the
dwclist.
-e Empty the dwclist.
-l List the contents of the dwclist list, one
name per line. If no command line switches
are given, this is the default.
Hints: The following should be noted:
* The +w option is not set by default. It must
be set explicitly to use the dwclist feature.
SKsh Amiga Shell Page 33 Reference Manual
* Use of long a long dwclist will slightly de-
grade the SKsh interpreter performance, al-
though commands in the list will run much
faster if passed parameters with wildcards.
* SKsh searches for the first argument verbatim
in the dwclist. This means that, for ex-
ample, if a program is added to the list as
"myprog", it must be invoked in the same
manner. Supplying a path name will not work,
unless the entire path is also added to the
list.
* SKsh does not care whether entries in the
list are external programs or internal built-
ins, functions, or aliases.
* If an alias or a function is used to invoke
an external command, both the alias or func-
tion name and the external command name must
appear in the dwclist. Otherwise, SKsh will
attempt to expand the wildcards for the one
not listed.
Example: dwclist -e # empty the dwclist
# now add these names...
dwclist -a zoo lharc
See Also: options (+w)
_________________________________________________________________
SKsh Amiga Shell Page 34 Reference Manual
_________________________________________________________________
Name: echo
Type: Builtin
Default: n/a
Usage: echo [-nc] [ parameter ... ]
Range: n/a
About: The echo command simply prints its arguments to stan-
dard output. If given no arguments, it prints a
newline. Otherwise, it prints its arguments, sepa-
rated by a single space, unless the -c option is set,
in which case no separating spaces are printed (con-
catenation mode). Echo normally prints a trailing
newline, unless the -n option is set, in which case
no trailing newline is printed.
'echo -c' is useful for concatenating strings:
result = $(echo -c This '+' That)
Example: echo 'These' 'arguments' are "echoed"
See Also:
_________________________________________________________________
SKsh Amiga Shell Page 35 Reference Manual
_________________________________________________________________
Name: eval
Type: Builtin
Default: n/a
Usage: eval [ string ... ]
Range: n/a
About: eval executes the text of the supplied strings as
if they were SKsh commands. If more than one
string is given, they are evaluated in order.
Example: foo='for a in a b c; do; echo $a; done'
eval "$foo" 'echo boo'
See Also:
_________________________________________________________________
SKsh Amiga Shell Page 36 Reference Manual
_________________________________________________________________
Name: exit
Type: Builtin
Default: n/a
Usage: exit [ code ]
Range: n/a
About: exit leaves SKsh, returning execution back to the
invoking shell. If invoked with a numeric argu-
ment, it returns that exit code to the invoking
shell or program.
Note that exit always exits SKsh entirely. To
simply exit a script or function, use the return
statement. If the LOGOUT variable is defined,
exit will execute that string before terminating.
Example: exit # exits successfully
See Also: return, LOGOUT
_________________________________________________________________
SKsh Amiga Shell Page 37 Reference Manual
_________________________________________________________________
Name: export
Type: Builtin
Default: n/a
Usage: export [ -l ] [ var ... ]
Range: n/a
About: export (without the -l option) does two things.
It sets the value of the indicated variables in
the topmost symbol table in SKsh, and it sets an
AmigaDos environment variable with the same name
and value. This is the only way to transfer vari-
able values between executions of SKsh.
export with the -l option only sets the topmost
symbol table of SKsh, but not the AmigaDos envi-
ronment variable. This is faster and does not
clutter up the environment with unneeded variable
definitions.
Example: export -l my_var1 my_var2
See Also: getenv
_________________________________________________________________
SKsh Amiga Shell Page 38 Reference Manual
_________________________________________________________________
Name: expr
Type: Keyword
Default: n/a
Usage: expr length string
expr num_expression
expr index str pattern
expr substr num1 num2
Range: n/a
About: expr evaluates and prints the results of an
expression.
expr length string
prints the length in characters of the string
expr num_expression
prints the result of evaluating num_expression.
num_expression is an integer expression com-
puted with 32 bit integers. '+', '-', '*',
'/', and '%' can be used. '*', '/', and '%'
have a higher precedence than '+' and '-'; oth-
erwise, the expression is evaluated left to
right. Parentheses can be used.
expr index str pattern
prints the index of pattern if found in the
string, or 0 if not found. The first position
in string is 1, not 0. Unlike ksh, pattern can
be more than one character.
expr substr string num1 num2
prints the substring of the string starting at
the position indicated by num1 and extending
for num2 characters. The beginning of the
string is at position one, not 0.
Example: expr 3 * ( 1 + 4 )
expr length "foo"
expr index 'foobarnot' 'bar'
expr substr 'foobarnot' 4 3
See Also:
_________________________________________________________________
SKsh Amiga Shell Page 39 Reference Manual
_________________________________________________________________
Name: extname
Type: Builtin
Default: n/a
Usage: extname [ -v ] [ fspec ]
Range: n/a
About: extname prints the "extension" of a given path
name. For example, the extension of my_file.c is
simply 'c'.
When used with the "-v" flag, extname prints that
part of the file name which is not in the
extension.
Example: extname my_file.c
See Also: basename, dirname
_________________________________________________________________
SKsh Amiga Shell Page 40 Reference Manual
_________________________________________________________________
Name: false
Type: Builtin
Default: n/a
Usage: false
Range: n/a
About: false simply returns a false exit code, and does
nothing else.
Example: if false
then
echo 'This will never echo'
fi
See Also: true
_________________________________________________________________
SKsh Amiga Shell Page 41 Reference Manual
_________________________________________________________________
Name: for/do/done
Type: Keywords
Default: n/a
Usage: for var in list do stmt_list done
Range: n/a
About: The variable is set to each value in list, and for
each value, the statement list is executed.
Example: for file in *.h *.c
do
cp $file $file.bak
done
See Also: while
_________________________________________________________________
SKsh Amiga Shell Page 42 Reference Manual
_________________________________________________________________
Name: force
Type: Keyword
Default: n/a
Usage: force [ -fba ] command [ parameter ... ]
Range: n/a
About: force forces SKsh to interpret command as a func-
tion, builtin, or alias. Exactly one of the 'f',
'b', and 'a' flags must be present. force is use-
ful if the builtin commands are redefined.
Example: function date {
echo -n 'The date is: '
force -b date
}
See Also:
_________________________________________________________________
SKsh Amiga Shell Page 43 Reference Manual
_________________________________________________________________
Name: function
Type: Keyword
Default: n/a
Usage: function name { stmt_list }
Range: n/a
About: function defines an SKsh function called name, and
with the definition given by the statement list.
Example: function my_func {
echo "I was passed $# parameters"
}
See Also: functions
_________________________________________________________________
SKsh Amiga Shell Page 44 Reference Manual
_________________________________________________________________
Name: functions
Type: Alias
Default: set -f
Usage: functions [ pattern... ]
Range: n/a
About: This alias lists defined functions. The pattern
uses normal wildcards, but must be quoted to avoid
being interpreted by the filename expansion
mechanism. If the pattern is omitted, all func-
tions are listed except those beginning with an
underscore character (hidden functions).
Only functions for the current context are listed,
so this command may have a different effect inside
of a subshell or function than when typed
manually.
Example: functions '[a-h]*'
See Also: set
_________________________________________________________________
SKsh Amiga Shell Page 45 Reference Manual
_________________________________________________________________
Name: getenv
Type: Builtin
Default: n/a
Usage: getenv [ var ... ]
Range: n/a
About: getenv imports the values of the indicated vari-
able from AmigaDos environment variables with the
same names. This command, coupled with export
command, allows variables to be transferred be-
tween executions of SKsh.
Example: getenv my_var1 my_var2
See Also: export
_________________________________________________________________
SKsh Amiga Shell Page 46 Reference Manual
_________________________________________________________________
Name: history
Type: Builtin
Default: n/a
Usage: history
history -n
history -e [ pattern | number | offset ]
Range: n/a
About: SKsh maintains the HISTSIZE previous commands in a
list so that they may later be recalled or edited
for re-execution.
history with no parameters simply prints the his-
tory list, with each line prefixed by the number
of the associated command. The -n parameter
leaves out the line numbers.
history -e is used to execute commands from the
history list. If given a positive numeric argu-
ment, it executes the history command at that num-
ber (note that these numbers are derived from CMD-
NUM and do not always begin at 1 if CMDNUM > HIST-
SIZE). If given a negative numeric argument, the
line executed is the 'nth' before the current;
thus, the example below executes the previous
command. If the argument is a string or pattern,
the most recent command containing that string or
pattern is executed.
Example: history -e -1 # execute previous command
See Also: HISTSIZE, !, !!, CMDNUM, command line editing in
the User's Manual.
_________________________________________________________________
SKsh Amiga Shell Page 47 Reference Manual
_________________________________________________________________
Name: HISTSIZE
Type: Variable
Default: 32
Usage: $HISTSIZE
Range: 0 to 32000
About: SKsh keeps a list of the $HISTSIZE most recent
commands available for editing and re-entry.
Example: HISTSIZE=64
See Also: history, options
_________________________________________________________________
SKsh Amiga Shell Page 48 Reference Manual
_________________________________________________________________
Name: HOME
Type: Variable
Default: :
Usage: $HOME
Range: n/a
About: This variable represents the default destination
for the cd command. It can be set to any valid
directory name.
Example: HOME=.
See Also: cd
_________________________________________________________________
SKsh Amiga Shell Page 49 Reference Manual
_________________________________________________________________
Name: if/then/elif/else/fi
Type: Keywords
Default: n/a
Usage: if expr then stmt_list
[ [ elif expr then stmt_list ] ... ]
[ else stmt_list ] fi
Range: n/a
About: If the expression is true (that is, it returns a
zero exit status), then the first statement list
is executed. If any elif statements are present,
each expression is executed, and if it is true,
execution procedes for the associated statement
list. If none of the expressions were true, the
else statement_list is executed.
The expressions can be any command, or a test ex-
pression surrounded by square brackets (see the
user's manual for details).
Example: if [ ! -f name -a ! -d name ]
then
mkdir name
else
echo "$name exists already!"
fi
See Also: while
_________________________________________________________________
SKsh Amiga Shell Page 50 Reference Manual
_________________________________________________________________
Name: IFS
Type: Variable
Default: " \n\t"
Usage: $IFS
Range: n/a
About: Characters in IFS are used to break substituted
text (from variables and command substitution)
into parameters. If IFS is set to the null string
(''), all substituted text will be a single
parameter.
If the 'i' option to SKsh is set (see the options
command), the IFS characters will also be used to
break text from $( ) style command substitution.
Example: [dh0:]: IFS=" \n\t"
[dh0:]: a='Now is the time'
[dh0:]: echo $a
Now is the time
[dh0:]: IFS=''
[dh0:]: echo $a
Now is the time
See Also:
_________________________________________________________________
SKsh Amiga Shell Page 51 Reference Manual
_________________________________________________________________
Name: inc
Type: Builtin
Default: n/a
Usage: inc var [ count ]
Range: n/a
About: inc increments the contents of the variable by
count, or 1 if count is not given. It is equiva-
lent to, but faster than, 'var=$(expr $var +
$count)'
Example: inc my_var 3
See Also: dec
_________________________________________________________________
SKsh Amiga Shell Page 52 Reference Manual
_________________________________________________________________
Name: info
Type: Builtin
Default: n/a
Usage: info [ -a ] [ device | directory ] ...
Range: n/a
About: info reports the amount of free space available on
a given device or directory. It prints total
space in kilobytes, used space in kilobytes, the
free space in kilobytes, the number of bytes per
block, the percentage capacity utilization, the
total number of errors, and the volume name. If
info is given a directory name as an argument, the
free space for the directory is the same as the
free space for the device on which the directory
resides.
The SKsh info command reports data in 1024 byte
kilobytes, not 1000 byte kilobytes. This may lead
to a slightly different answer than other info
commands. The SKsh info command will deal cor-
rectly with file systems of up to several
gigabytes (should you happen to have one of
those).
If the info command is given the -a flag, it will
report information on all the currently mounted
devices.
Example: info sys: ram: df0:
info -a # info for all devices
See Also:
_________________________________________________________________
SKsh Amiga Shell Page 53 Reference Manual
_________________________________________________________________
Name: LASTRC
Type: Variable
Default: n/a
Usage: $LASTRC
Range: n/a
About: LASTRC stores the return code from the last exter-
nal command which was executed. It is not reset
by subsequent internal command return codes, as is
$?.
Example: some_external_command
echo
if [ $LASTRC -ne 0 ]
then
echo 'command failed!'
fi
See Also: $?
_________________________________________________________________
SKsh Amiga Shell Page 54 Reference Manual
_________________________________________________________________
Name: LINES
Type: Variable
Default: 24
Usage: $LINES
Range: 3 to anything
About: This variable is currently not used by SKsh; it is
provided for future expansion, and for other ap-
plications or programs which might be interested.
This variable is automatically set by SKsh when
the window is resized. This behavior can be
turned off with the options command.
Example: if [ $LINES -lt 20 ]
then
echo "We require at least 20 lines!"
fi
See Also: COLUMNS, options
_________________________________________________________________
SKsh Amiga Shell Page 55 Reference Manual
_________________________________________________________________
Name: ll
Type: Alias
Default: ls -lbF
Usage: ll [ file | dir ] ...
Range: n/a
About: ll prints a long format directory listing, with
only the basename of each file printed. Note that
the 'F' option to 'ls' is set.
Example: ll s:
See Also: dir, ls
_________________________________________________________________
SKsh Amiga Shell Page 56 Reference Manual
_________________________________________________________________
Name: LLMIN
Type: Variable
Default: 4
Usage: $LLMIN
Range: 0 to 1023 inclusive
About: LLMIN stores the minimum command line length for
which SKsh will store the line in the history
list. Put another way, lines shorter than this
value are not inserted into the history list. For
example, a line containing only "cd" would be ig-
nored, as it is just as easy to re-type as it is
to search for in the history list.
Example: LLMIN=0 # don't ignore any lines, even short ones
See Also: MAXDIST, options
_________________________________________________________________
SKsh Amiga Shell Page 57 Reference Manual
_________________________________________________________________
Name: local
Type: Builtin
Default: n/a
Usage: local [ varname ... ]
Range: n/a
About: The local command can be used to enforce the cre-
ation of local variables if the 'N' option and the
'l' to SKsh are set (see the options command).
Normally with the 'N' option set, local variables
are created only if they had not been created
first in an enclosing context. The local command
makes them local even if there had been a previ-
ously defined variable of the same name in an en-
closing context. Note that this command will have
no effect if SKsh local variables are disabled by
turning off the 'l' option.
Example: function my_func {
local answer;
answer = 42
}
See Also: options
_________________________________________________________________
SKsh Amiga Shell Page 58 Reference Manual
_________________________________________________________________
Name: LOGOUT
Type: Variable
Default: 'echo "\nBye!\n"'
Usage: $LOGOUT
Range: n/a
About: The text of this variable is executed by SKsh when
the exit command is used to terminate execution.
Example: LOGOUT=''; # do nothing
See Also: exit
_________________________________________________________________
SKsh Amiga Shell Page 59 Reference Manual
_________________________________________________________________
Name: ls
Type: Builtin
Default: n/a
Usage: ls [ -aldhi1bvF ] [ dirname | fname ] ...
Range: n/a
About: This command is used to obtain information about
files or directories. With no arguments, it sim-
ply lists the contents of the current working di-
rectory, leaving out files beginning with a dot.
If the 'I' option to SKsh is set (see the options
command), all .info files are also left out (this
feature exists because I hate .info files).
The 'a' option causes ls to list files beginning
with a dot. Similarly, the 'i' option lists .info
files even if the 'I' option to SKsh is set. The
'h' option lists files with the hidden bit set.
The 'l' option creates a long format list, with
filename, protection status, byte size, block
size, and modification date listed. (The ll com-
mand has been aliased to 'ls -l' to make this
easier).
The '1' option creates a short format list with
one column instead of three (useful for piping
filenames into a command).
The 'd' option forces directories to be printed as
such. Normally if the ls command is given a di-
rectory as an argument, it prints the contents of
that directory. The 'd' option prints information
on the directory itself. This is useful with the
'l' option to find the modification date or pro-
tection status of a directory.
The 'b' option causes only the basename of each
file to be printed. Normally, if a path to a file
is given, SKsh will print the path information in
each entry in the ls output. The 'b' option
leaves out the path information, printing only the
basename.
The 'v' option prints a count of entries listed
after the listing itself. Also, a total byte
count is printed, which is the sum of the sizes of
each file listed.
SKsh Amiga Shell Page 60 Reference Manual
The 'F' option instructs 'ls' to output the appro-
priate _FILE_S, _FILE_E, _DIR_S, _DIR_E, _EXEC_S,
and _EXEC_E variables before and after each file
name printed in either the short or long directory
format. See the documentation on those variables
for details on their usage.
The short form of the ls command normally prints
the files in columns. To decide how many columns
there should be, it examines the $COLUMNS vari-
able, divides the result by the length of the
longest file name to be printed, and insures at
least a three character gutter between columns.
The ls command outputs an error message if passed
an argument which does not exist as a file or
directory.
Example: ls -li my_dir # list my_dir including info files
See Also: options, dir, ll
_________________________________________________________________
SKsh Amiga Shell Page 61 Reference Manual
_________________________________________________________________
Name: match
Type: Builtin
Default: n/a
Usage: match [ -v ] pattern [ string ... ]
Range: n/a
About: match prints each string that matches the pattern
given in the first argument. The pattern is of
the same type used by SKsh for filename wildcards,
but it must be quoted to avoid being expanded in
that manner. If the 'v' flag is set, only strings
not matching the pattern are printed.
Example: match '*.[ch]' file1.foo file1.c file2.h my_file
See Also:
_________________________________________________________________
SKsh Amiga Shell Page 62 Reference Manual
_________________________________________________________________
Name: MAXDIST
Type: Variable
Default: 5
Usage: $MAXDIST
Range: 0 to 32000 inclusive
About: When a command is entered from the keyboard with
line editing enabled, SKsh checks for an identical
line in the history list. If one is found less
than $MAXDIST lines away, the new one is not en-
tered into the history list. This has two benefi-
cial effects. First, if the same command is en-
tered several times in a row, it will only appear
once in the history list. Second, commands which
have not been entered for a long time will be en-
tered again so they do not scroll of the end of
the list. This rule applies whether the command
was typed or accessed from a previous history list
entry.
Example: MAXDIST=10 # re-enter lines if they get too far
See Also: LLMIN, options
_________________________________________________________________
SKsh Amiga Shell Page 63 Reference Manual
_________________________________________________________________
Name: mem
Type: Builtin
Default: n/a
Usage: mem [ -tcf ]
Range: n/a
About: mem reports the amount of free chip and fast
memory, as well as a total. If the 't' flag is
set, only the total is printed. If the 'c' is
set, only chip memory is listed, and if the 'f'
flag is set, only fast memory is listed.
Example: if [ $(mem -t) -lt 400000 ]
then
echo 'you must have at least 400K free'
fi
See Also:
_________________________________________________________________
SKsh Amiga Shell Page 64 Reference Manual
_________________________________________________________________
Name: mkdir
Type: Builtin
Default: n/a
Usage: mkdir [ dirname ... ]
Range: n/a
About: mkdir creates directories with names identical to
the parameters passed to it.
Example: mkdir my_dir sys:system/my_other_dir
See Also: rmdir
_________________________________________________________________
SKsh Amiga Shell Page 65 Reference Manual
_________________________________________________________________
Name: mv
Type: Builtin
Default: n/a
Usage: mv [ -v ] source1 [ source2 ... ] destination
Range: n/a
About: mv moves files or directories by renaming them.
Thus, it cannot be used to move data cross
devices. If more than one source is given, the
destination must be a directory or nonexistant.
If it is nonexistant, it is created as a
directory.
The -v option prints the name of each file as it
is moved.
Example: mv my_dir sys:another_dir/my_other_dir
See Also: cp
_________________________________________________________________
SKsh Amiga Shell Page 66 Reference Manual
_________________________________________________________________
Name: OLDPWD
Type: Variable
Default: old present working directory string
Usage: $OLDPWD
Range: n/a
About: When the present working directory is changed,
SKsh puts the old PWD value into OLDPWD. The cd -
p command can be used to return to OLDPWD.
Example: echo $PWD; cd c:; echo $OLDPWD
See Also: PWD, pwd, cd
_________________________________________________________________
SKsh Amiga Shell Page 67 Reference Manual
_________________________________________________________________
Name: options
Type: Builtin
Default: n/a
Usage: options [ -opts | +opts ] ...
Range: n/a
About: The options command provides a way to change the
default behavior of SKsh in a number of areas. If
the command is entered with no parameters, simply
prints the current options string, which is a se-
ries of letters and digits. Otherwise, it exam-
ines each parameter in turn. Each parameter can
begin with a '+' or '-'; a '+' turns "on" the op-
tions corresponding each letter, and a '-' turns
them "off".
+1 Set the overstrike/insert mode back to the
default value after a return. If this flag
is not set, the overstrike/insert mode re-
mains set to what it was previously.
+c If set, SKsh wildcard expansion, filename
completion, and a few other features will be
case independent. If unset, they will be
case dependent.
+e If set, disable command line editing. This
might be useful for using SKsh from a termi-
nal that does not support the ANSI escape se-
quences SKsh uses for line editing. Note
that is flag is SET in .skshinit. You must
reset it in .skshrc if you wish to use line
editing (the .skshrc file supplied with SKsh
does this).
+f If set, disable wildcard filename expansion.
+h If set, always create a new history line,
even if an old command was executed with
'history -e' or the interactive editing
facility. If not set, executing old lines
will not create a new history entry.
+i If set, use IFS to split $( ) command substi-
tution text, much as it is used to split
variable value expansion text.
+l If set, variables referenced in functions or
SKsh Amiga Shell Page 68 Reference Manual
parenthetical subshells will be local (al-
though this also depends on the 'n' option).
If not set, there will be no local variables.
Note that resetting this flag may have large
side effects when running scripts and
functions. The advantage is that it takes
less memory and is faster.
+n If set, only read scripts, but do not execute
their commands. This is ignored for interac-
tive use.
+p If set, use the exec prompt string mode.
This tells sksh not to use the prompt string
as the prompt directly, but rather to pass it
through the command interpreter first, and
use the results as the prompt. This is
slower, but more powerful.
+s If set, sort filename parameters from
wildcard expansion.
+v If set, variable expansions which contain
wildcard characters will use those wildcard
characters in filename matching. For ex-
ample, if the "foo" variable contains "*",
then "echo $foo.bar" would echo any file name
ending with ".bar". If the v flag is RESET,
then it would simply echo "*.bar"; ie, the
value of the variable would be substituted
but ignored for filename matching.
+w If set, SKsh will use the dwclist to selec-
tively bypass wildcard file expansion on a
command by command basis. It is reset by
default.
+x If set, print each lines as it is executed.
Moderately useful for debugging scripts.
+C Enable the internal completion list. See the
complist command for details. If reset, the
internal completion list will be ignored.
+F If set, map UNIX style filenames to AmigaDos
style file names. A leading '/' becomes a
':', a '~' inserts the contents of the HOME
variable, a '.' becomes the current direc-
tory, and two dots become a slash.
+I If set, leave out the .info files from direc-
tory listings unless the 'i' option to 'ls'
is explicitly set.
SKsh Amiga Shell Page 69 Reference Manual
+N Create new variables in a subshell or func-
tion only if a variable with the same name
does not exist in an outer context. If one
does exist, that one will be used instead of
making a new local variable. This flag
changes the scoping rules, and can have a
large effect in the execution of scripts and
functions; it should be used with care.
+O Use overstrike instead of insert mode as the
default for command line editing.
+P If set, ^r history searches and 'history -e'
style history access will only match lines
beginning with the given string. If unset,
the string can match any location within a
history line.
+R Disable automatic setting of LINES and COL-
UMNS variables. Normally, these variables
are set after the window is re-sized at the
next interactive prompt. To set them manu-
ally and not be overridden by SKsh, use this
options flag.
+S Insert a single blank line before and after
the prompt when typing commands
interactively. For interlace screens where
more than 36 or so lines are displayed, using
the S option can create a more visually ap-
pealing and "tidy" display.
+U The U option, if set, causes SKsh to use a
requester if a component of the path contains
an unmounted volume. This also affects sev-
eral other areas, such as the '-m' test
expression.
Example: # see which options are turned on:
options
# reset all options:
options $(echo -c - '-' $(options))
See Also:
_________________________________________________________________
SKsh Amiga Shell Page 70 Reference Manual
_________________________________________________________________
Name: PATH
Type: Variable
Default: '.,c:'
Usage: $PATH
Range: n/a
About: This variable contains a comma separated list of
directory names. When SKsh executes a file, it
searches for it in these directories. Note that
the current working directory must be specified
explicitly ("."). This lets you change the order
of the search. For example, you could move "." to
the end of the path to search it last. The direc-
tory names in the path do not need to be termi-
nated by a slash; SKsh will add one if it is not
there.
If SKsh finds the file name in the search path,
and the file has its script bit set, SKsh will at-
tempt to execute this file as a script instead of
a binary.
The PATH variable is also used by the which and
whence commands.
Entries in the path which are on currently un-
mounted devices are bypassed silently, although
this behavior can be changed with the options
command.
Example: c:run $(which emacs) my_file
See Also: path, which, whence
_________________________________________________________________
SKsh Amiga Shell Page 71 Reference Manual
_________________________________________________________________
Name: path
Type: Function
Default: see the .skshinit file
Usage: path
path name
path -add [ name ... ]
Range: n/a
About: This function is provided to make the PATH vari-
able easier to set up and manipulate.
With no arguments, path simply prints the current
path definition.
The second form above sets the path variable to
name.
The third form above adds each name to the path
variable list, provided that it is not there
already. If the name is already a component of
the path, it is ignored.
Example: path -add sys:bin sys:pd/bin
See Also: PATH
_________________________________________________________________
SKsh Amiga Shell Page 72 Reference Manual
_________________________________________________________________
Name: PNPC
Type: Variable
Default: 21
Usage: $PNPC
Range: 0 to 63
About: This variable is one of several responsible for
controlling the actions of SKsh line editing and
display output. PNPC tells SKsh how many non-
printing control characters there are in the cur-
rently defined prompt strings (both PS1 and PS2).
SKsh needs to know this so that it can find the
actual printing width of the prompt string from
the actual character length. You will only have
to change PNPC if you change the number of ANSI
control sequences in your prompt.
Example: PNPC=0
See Also: COLUMNS, PS1, PS2, options
_________________________________________________________________
SKsh Amiga Shell Page 73 Reference Manual
_________________________________________________________________
Name: preparse
Type: Builtin
Default: n/a
Usage: preparse < infile > outfile
Range: n/a
About: preparse reads a legal SKsh script from its stan-
dard input and produces a "preparsed" file on its
standard output. This preparsed file can then be
read back into SKsh much (2 to 3 times) faster
than a normal SKsh script file. The preparsed
file acts just like a script file; if it has its
script bit set, it can be automatically executed
by typing its name. It can also be sourced. How-
ever, it is not in a human readable format.
SKsh guarantees that script files will be upwardly
compatible between versions of SKsh; however,
preparsed files will not be. Therefore, the
source scripts must be retained.
SKsh will automatically detect preparsed versions
of the .skshinit and .skshrc files (called
.skshinit.pp and .skshrc.pp) and use those if they
exist. This can dramatically reduce SKsh invoca-
tion time.
SKsh will issue an error message if you try to ex-
ecute a preparsed file from an old version of
SKsh.
Preparsing files will probably make a significant
difference only if the file is later read from a
hard disk or a ram drive. From a floppy, SKsh can
parse the file nearly as fast as the floppy can
read it.
Example: preparse < Stuff.sksh > Stuff.sksh.pp
See Also: Addendum1.5.doc for an example of how to source
other preparesed files from your .skshrc file.
_________________________________________________________________
SKsh Amiga Shell Page 74 Reference Manual
_________________________________________________________________
Name: printf
Type: Builtin
Default: n/a
Usage: printf formatstring parameters...
Range: n/a
About: printf is similar to the C function of the same
name. The first parameters is the format string,
and the rest are inserted appropriately. Note
that there are no associated fprintf and sprintf
functions, as those can be easily accomplished
with "var=$(printf)" or "printf >>file".
The echo statement should be used when no format-
ting is needed.
Notes: To print integers, "%ld" should always be used in-
stead of "%d".
The "%c" option does not work. Instead, use %s
with a one character string.
Any argument beginning with "-" or a digit will be
converted to a 32 bit integer before being passed
to printf. This is necessary as SKsh stores all
values internally as strings. If you wish to use
such a parameter with the "%s" format, prefix it
with a leading space.
The result string must fit within one SKsh token
(1023 characters). SKsh does not check for over-
flow, so it would be advisable to heed this limit.
Example: printf "Test: %10s %5ld" FOO 42
See Also: echo
_________________________________________________________________
SKsh Amiga Shell Page 75 Reference Manual
_________________________________________________________________
Name: ps
Type: Builtin
Default: n/a
Usage: ps
Range: n/a
About: ps prints, for each CLI process, the process num-
ber, the address of the process, the priority of
the process, the command name associated with the
process, and the current working directory for the
process.
Example: ps
See Also:
_________________________________________________________________
SKsh Amiga Shell Page 76 Reference Manual
_________________________________________________________________
Name: PS1
Type: Variable
Default: '$_ANSI_P3[$PWD]: $_ANSI_P1'
Usage: $PS1
Range: n/a
About: This variable controls the primary prompt string
displayed by SKsh. If the 'p' SKsh option is not
set (see options), SKsh expands the variables in
the string, and outputs it as the primary prompt.
For this reason, PS1 should be defined to a single
quoted string, so that the variables are expanded
at the proper time and not when PS1 is defined.
If the 'p' option to SKsh is set, SKsh sends the
contents of the PS1 variable through the command
interpreter, and displays the result as the pri-
mary prompt. In this case, PS1 should contain a
string which when executed, will print the desired
prompt. This is slower than the default method
above.
Example: PS1='$ '; PNPC=0
See Also: PS2, PNPC, options
_________________________________________________________________
SKsh Amiga Shell Page 77 Reference Manual
_________________________________________________________________
Name: PS2
Type: Variable
Default: '$_ANSI_P3> $_ANSI_P1'
Usage: $PS2
Range: n/a
About: This variable controls the secondary prompt string
displayed by SKsh. This is the prompt string dis-
played when SKsh expects more input, such as the
continuation of a for statement or unterminated
string.
If the 'p' SKsh option is not set (see options),
SKsh expands the variables in the string, and out-
puts it as the secondary prompt. For this reason,
PS2 should be defined to a single quoted string,
so that the variables are expanded at the proper
time and not when PS2 is defined.
If the 'p' option to SKsh is set, SKsh sends the
contents of the PS2 variable through the command
interpreter, and displays the result as the sec-
ondary prompt. In this case, PS2 should contain a
string which when executed, will print the desired
prompt. This is slower than the default method
above.
Example: PS2=': '; PNPC=0
See Also: PS1, PNPC, options
_________________________________________________________________
SKsh Amiga Shell Page 78 Reference Manual
_________________________________________________________________
Name: PWD
Type: Variable
Default: present working directory string
Usage: $PWD
Range: n/a
About: SKsh maintains the contents of this variable such
that it always represents the current working
directory.
Example: old_dir="$PWD"; # save old directory
See Also: OLDPWD, pwd, cd
_________________________________________________________________
SKsh Amiga Shell Page 79 Reference Manual
_________________________________________________________________
Name: pwd
Type: Alias
Default: echo "$PWD"
Usage: pwd
Range: n/a
About: This alias simply prints the present working di-
rectory string.
Example: pwd
See Also: PWD, OLDPWD
_________________________________________________________________
SKsh Amiga Shell Page 80 Reference Manual
_________________________________________________________________
Name: quit
Type: Alias
Default: LOGOUT=""; exit
Usage: pwd
Range: n/a
About: quit is like exit but does not execute the value
of the LOGOUT variable first.
Example: pwd
See Also: exit, logout, LOGOUT
_________________________________________________________________
SKsh Amiga Shell Page 81 Reference Manual
_________________________________________________________________
Name: read
Type: Builtin
Default: n/a
Usage: read var
Range: n/a
About: The read command sets the value of the variable by
reading exactly one command from the standard
input. This can be used to accept input from the
keyboard, or it can have its own standard input
redirected to read lines from a file. Read re-
turns a non-zero return code when it encounters an
end-of-file; this is useful in loops.
Example: while read in_line
do
echo "We read: $in_line"
done < my_input_file.txt
See Also:
_________________________________________________________________
SKsh Amiga Shell Page 82 Reference Manual
_________________________________________________________________
Name: resident
Type: Builtin
Default: n/a
Usage: resident [ -l ]
resident [ -a | -d ] [ progname ... ]
Range: n/a
About: The resident command can be used to examine the
resident list, add programs to it, or delete pro-
grams from it. "resident" with no arguments or
with the "-l" flag lists the programs currently on
the resident list. The -a flag adds the named
programs to the resident list; the whole path to
the file must be given, although only the basename
is remembered. Resident -d deletes programs from
the resident list.
Example: resident -a /bin/view # add view to res list
resident -l # list resident list
See Also: which
_________________________________________________________________
SKsh Amiga Shell Page 83 Reference Manual
_________________________________________________________________
Name: return
Type: Builtin
Default: n/a
Usage: return [ num ]
Range: n/a
About: The return command exits from an enclosing script,
subshell, or function. If given a numeric argu-
ment, it exits from the nth enclosing script, sub-
shell, or function.
Example: ( echo foo; return; echo 'This is not echoed' )
See Also: continue, break
_________________________________________________________________
SKsh Amiga Shell Page 84 Reference Manual
_________________________________________________________________
Name: rm
Type: Builtin
Default: n/a
Usage: rm [ -rv ] [ file | dir ] ...
Range: n/a
About: This command simply removes the named files. It
will not remove directories unless the '-r' flag
is used; use rmdir to remove a single, empty
directory.
The '-r' flag causes 'rm' to recursively remove
everything under each directory. This is somewhat
dangerous; care should be used.
The '-v' flag prints the name of each file as it
is removed.
Example: rm scrap_file.c
See Also: rmdir
_________________________________________________________________
SKsh Amiga Shell Page 85 Reference Manual
_________________________________________________________________
Name: rmdir
Type: Builtin
Default: n/a
Usage: rmdir [ dir ... ]
Range: n/a
About: This command simply removes the named directories.
It will not remove files or directories which are
not empty.
Example: rmdir scrap_dir
See Also: rmdir
_________________________________________________________________
SKsh Amiga Shell Page 86 Reference Manual
_________________________________________________________________
Name: ROOT
Type: Variable
Default: ":"
Usage: path names beginning with '/'
Range: Any legal directory or filesystem device name
About: When Un*x filename mapping is used (see the op-
tions command), SKsh replaces a leading slash with
the contents of this variable. It is normally a
colon, which makes the path name become relative
to the "root" of the current device. However, it
can be set to any directory or filesystem device
name. For example, if set to "sys:", all file
references beginning with a slash will become
relative to 'sys:', even if the current working
directory is on another device. If can also be
set to a subdirectory of a device, as in the ex-
ample below, in which case it must end with a
slash.
Example: ROOT=sys:usr/work/ # make this the new "root"
See Also: options
_________________________________________________________________
SKsh Amiga Shell Page 87 Reference Manual
_________________________________________________________________
Name: set
Type: Builtin
Default: n/a
Usage: set [ -fabvs ] [ pattern ... ]
Range: n/a
About: With no options, set lists each variable and its
definition. If pattern arguments, each one is
listed. The 'f' options forces interpretation as
function names, the 'a' option as alias names, the
'b' option as builtin command names, and the 'v'
option as variables names (the default).
The 's' option leaves out the definition, printing
only the name on a single line. In any case,
function definitions are not listed in this ver-
sion of SKsh. If the 's' option is used, the 'v'
option must explicitly be set to list variables.
Also, more than one of 'f', 'a', 'b', and 'v' may
be set.
SKsh will not list any function, alias, builtin,
or variable whose name begins with an underscore
(hidden variables, etc). This is useful to either
hide definitions from users, or in cases where
printing the contents of a variable would corrupt
the display (such as the _ANSI_CLEAR variable).
The definition of builtin commands is printed as a
short description of the command.
The set command cannot be used to set variables,
as in csh. Use the assignment operator ('=') for
that.
Example: set -b '[a-d]*'
See Also: unset
_________________________________________________________________
SKsh Amiga Shell Page 88 Reference Manual
_________________________________________________________________
Name: setmap
Type: Builtin
Default: n/a
Usage: setmap -r
setmap -s map [{key|code} {fn|"@map"|"!macro"}]...
setmap -n mapnum ...
setmap -e exitmap mapnum ...
setmap -m macronum [ fn | string ] ...
Range: 32 definable key maps ( 0 to 31)
256 entries per key map
32 definable key macros ( 0 to 31 )
64 byte maximum key macro size
About: The setmap command is used to define SKsh keyboard
editing maps. SKsh is capable of emulating most
popular editor styles to a reasonable degree. The
UserMan.doc file discusses the theory of SKsh key
maps in greater detail; this is just intended as a
reference guide. Pleas read that section as well.
"setmap -r" resets all keymaps and key macros to
their default (dumb) state.
"setmap" alone or with an optional -s flag is used
to set keymaps. The first argument is integer be-
tween 0 and 31 indicating the keymap to change.
All subsequent arguments are grouped in pairs; the
first of the pair is a character (such as "A") or
an ascii code (such as 08). The second of the
pair is one of:
1) a function name (such as "DEL"). In this
case the function will be executed when the
key is pressed.
2) another keymap number prefixed by '@'. In
this case the new keymap will become the
current keymap when the key is pressed.
3) a macro number prefixed by '!'. In this
case the macro will be executed when the key
is pressed.
"setmap -n" sets the keymaps to be non-exiting
keymaps. In other words, after a function is ex-
ecuted in the current keymap it remains the cur-
rent keymap.
SKsh Amiga Shell Page 89 Reference Manual
"setmap -e" sets the keymaps to be "exiting"
keymaps which exit to keymap "exitmap" after one
function.
"setmap -m" defines a numbered macro (macronum) to
be a series of functions or strings.
Notes: The following are legal keymap functions when used
with "setmap -s" or "setmap -m"
INS - insert typed character
NOP - perform no operation
ACC - "accept" and execute line
REP - set repeat count
FNK - execute function key
BS - backspace
BOL - move to beginning of line
ZAP - delete all of current line
DEL - delete one character forward
EOL - move to end of line
RHT - move cursor right one character
LFT - move cursor left one character
KEL - kill to end of the line
UP - move to previous history line
DN - move to next history line
EXE - "execute" line and move to next
FWW - move forward one word
BKW - move backward one word
BDW - backward delete word (before cursor)
DLW - delete word (in front of cursor)
SRH - search for text in history list
CC1 - command completion type 1 (esc esc)
CC2 - command completion type 2 (esc =)
CC3 - command completion type 3 (esc *)
HOL - head of list (first history line)
TOL - tail of list (last history line)
ILP - insert last parameter of previous line
ILT - insert tail of previous line
TIM - toggle insert mode
RDL - redraw current line
SPC - switch two previous characters
GK0 - goto keymap 0 (for use in macros)
GK1 - goto keymap 1 (for use in macros)
GK2 - goto keymap 2 (for use in macros)
GK3 - goto keymap 3 (for use in macros)
GK4 - goto keymap 4 (for use in macros)
Example: # reset all keymaps
setmap -r
# set keymaps 1 and 3 to be non-exiting
setmap -n 1 3
SKsh Amiga Shell Page 90 Reference Manual
# set keymaps 2 and 4 to exit to keymap number 1
setmap -e 1 2 4
# set macro number 0 to move to the beginning of
# the line, insert a '#', and accept the line
setmap -m 0 BOL '#' ACC
# set the "esc" key to move to keymap 1, the "del"
# key to delete a character, and the "~" key to
# execute macro number 5
setmap -s 0 27 @1 04 DEL '~' '!5'
See Also: UserMan.doc:
Advanced Topics: Definable Keyboard Editing
_________________________________________________________________
SKsh Amiga Shell Page 91 Reference Manual
_________________________________________________________________
Name: SHELL
Type: Variable
Default: sksh
Usage: $SHELL
Range: n/a
About: This variable is set by SKsh to the string "sksh".
It can be used to test which shell is running,
provided that the alternate shell has a similar
syntax.
Example: if [ "$SHELL" != 'sksh' ]
then
echo "This runs only under SKsh!"
fi
See Also: SYSNAME
_________________________________________________________________
SKsh Amiga Shell Page 92 Reference Manual
_________________________________________________________________
Name: shift
Type: Builtin
Default: n/a
Usage: shift [ num ]
Range: n/a
About: This command is used inside of scripts or func-
tions to shift the parametric arguments. For ex-
ample, if $1 = 'foo' and $2 = 'bar', after a
shift, $1 would be 'bar' and $2 would not be set.
The '$#' and '$*' variables are also modified
appropriately. If shift is given a numeric param-
eter, it acts as though num consecutive shifts
took place.
Example: function my_func {
echo "$2, $#"
shift
echo "$2, $#"
}
See Also: function
_________________________________________________________________
SKsh Amiga Shell Page 93 Reference Manual
_________________________________________________________________
Name: SIZE
Type: Variable
Default: "normal" for plain SKsh
"tiny" for tiny_SKsh
Usage: $SIZE
Range: n/a
About: This variable can be used to test the shell under which a
script or function is being run.
Example: if [ "$SIZE" = 'normal' ]
then
echo 'This is normal SKsh'
else
echo 'This is tiny_SKsh'
fi
See Also:
_________________________________________________________________
SKsh Amiga Shell Page 94 Reference Manual
_________________________________________________________________
Name: sleep
Type: Builtin
Default: n/a
Usage: sleep n
Range: n/a
About: Sleep delays execution for n seconds. If n is
omitted, zero, or negative, the command does not
pause. Sleep takes virtually no CPU time. It
will wake up once per second to check for the
break key. Sleep is not guaranteed to be a delay
of exactly n seconds; it may be more on a loaded
system, or if SKsh is preempted by a higher prior-
ity process. It is, however, guaranteed to be a
delay of at least n seconds.
Example: time sleep 5
See Also: time
_________________________________________________________________
SKsh Amiga Shell Page 95 Reference Manual
_________________________________________________________________
Name: source
Type: Builtin
Default: n/a
Usage: source [ file ... ]
Range: n/a
About: This command "sources" the named files; that is,
they are executed, but not in a subshell, so that
any variables, alias, etc, that they define are
really defined in the parent's environment.
A single dot ('.') may be used to source a file as
well; this is compatible with ksh and sh.
A file which is sourced does not have to have its
script bit set (although it won't hurt). However,
a script file which is to be executed by typing
its name must have its script bit set.
Executing a file is equivalent to:
( source file )
Example: source my_init_file.sksh
See Also:
_________________________________________________________________
SKsh Amiga Shell Page 96 Reference Manual
_________________________________________________________________
Name: stack
Type: Function
Default: n/a
Usage: obsolete
Range: n/a
About: This function was obsoleted in SKsh 1.5. See the
Addendum1.5.doc file for an explanation.
Example:
See Also: Addendum1.5.doc
_________________________________________________________________
SKsh Amiga Shell Page 97 Reference Manual
_________________________________________________________________
Name: SYSNAME
Type: Variable
Default: 'Amiga'
Usage: $SYSNAME
Range: n/a
About: This variable describes the system on which SKsh
is currently being run. There is currently only
one version of SKsh, so this variable will contain
"Amiga". If SKsh is ported to other systems, this
variable can be used to determine the name of the
system.
Example: if [ "$SYSNAME" != 'Amiga' ]
then
echo "This script runs only on Amigas."
fi
See Also: SHELL
_________________________________________________________________
SKsh Amiga Shell Page 98 Reference Manual
_________________________________________________________________
Name: time
Type: Keyword
Default: n/a
Usage: time statement
Range: n/a
About: time executes the statement and prints the execu-
tion time in seconds.
Example: time ( dir; sleep 2 )
See Also:
_________________________________________________________________
SKsh Amiga Shell Page 99 Reference Manual
_________________________________________________________________
Name: touch
Type: Builtin
Default: n/a
Usage: touch [ file ... ]
Range: n/a
About: touch create the named files if they do not exist,
and in any case updates the file modification
timestamp. It also resets the AmigaDos archive
bit.
Example: touch aaa bbb ccc
See Also:
_________________________________________________________________
SKsh Amiga Shell Page 100 Reference Manual
_________________________________________________________________
Name: true
Type: Builtin
Default: n/a
Usage: true
Range: n/a
About: true simply returns a true exit code, and does
nothing else.
Example: while true
do
echo 'repeat forever!'
sleep 1
done
See Also: false
_________________________________________________________________
SKsh Amiga Shell Page 101 Reference Manual
_________________________________________________________________
Name: unalias
Type: Alias
Default: unset -a
Usage: unalias [ name ... ]
Range: n/a
About: This alias removes existing aliases from the cur-
rent context. If no names are given, the command
has no effect. Otherwise, each alias listed is
removed, if it was in fact an alias.
SKsh supplied aliases may be removed, but this is
not recommended.
Example: unalias my_alias my_other_alias
See Also: unset
_________________________________________________________________
SKsh Amiga Shell Page 102 Reference Manual
_________________________________________________________________
Name: unfunc
Type: Alias
Default: unset -f
Usage: unfunc [ name ... ]
Range: n/a
About: This alias removes existing functions from the
current context. If no names are given, the com-
mand has no effect. Otherwise, each function
listed is removed, if it was in fact an function.
SKsh supplied functions may be removed, but this
is not recommended.
Example: unfunc my_function my_other_function
See Also: unset
_________________________________________________________________
SKsh Amiga Shell Page 103 Reference Manual
_________________________________________________________________
Name: unset
Type: Builtin
Default: n/a
Usage: unset [ -favb ] [ name ... ]
Range: n/a
About: This command removes the definition of functions,
aliases, variables, or builtins (controlled by the
f, a, v, or b flags). If no flag is given, the
default is to remove variable definitions.
Unsetting a builtin (with the -b option) does not
cause actual code to be removed from memory; it
simply removes all internal references to that
command, such that it appears to no longer exist.
This can cause problems if not used carefully;
only attempt this if you are sure you know what
effects this will have. For example, if you re-
move the 'exit' builtin, you will not be able to
quit SKsh.
Example: unset -f my_func1 my_func2
See Also: unfunc, unalias
_________________________________________________________________
SKsh Amiga Shell Page 104 Reference Manual
_________________________________________________________________
Name: variables
Type: Alias
Default: set -v
Usage: variables [ -s ] [ pattern ... ]
Range: n/a
About: This alias lists defined variables. The pattern
uses normal wildcards, but must be quoted to avoid
being interpreted by the filename expansion
mechanism. If the pattern is omitted, all vari-
ables are listed except those beginning with an
underscore character (hidden variables). For ex-
ample, _ANSI_P1 is a hidden variable; if it was
printed in the normal variable list, the display
pen would be changed.
Only variables for the current context are listed,
so this command may have a different effect inside
of a subshell or function than when typed
manually.
Example: variables -s '[A-H]*'
See Also: set
_________________________________________________________________
SKsh Amiga Shell Page 105 Reference Manual
_________________________________________________________________
Name: version
Type: Builtin
Default: n/a
Usage: version [ -ds ]
Range: n/a
About: version with no options prints the SKsh version
string and copyright notice. The 'd' option ech-
oes the compile date of SKsh, and the 's' option
prints a single numeric value that will be
incremented for each release of SKsh. This is
useful in tests, as below.
Example: if [ $(version -s) -lt 3 ]
then
echo 'This script requires a later SKsh
version'
fi
See Also:
_________________________________________________________________
SKsh Amiga Shell Page 106 Reference Manual
_________________________________________________________________
Name: whence
Type: Builtin
Default: n/a
Usage: whence [ name ... ]
Range: n/a
About: whence reports how each name would be interpreted
if it was used as a command. It will report
whether the name will be interpreted as a builtin
command, an alias, a function, or an external
statement. If the command is interpreted as an
external statement, a path to the command is
printed.
Example: whence whence if path ll
See Also: which
_________________________________________________________________
SKsh Amiga Shell Page 107 Reference Manual
_________________________________________________________________
Name: which
Type: Builtin
Default: n/a
Usage: which [ -s ] [ name ... ]
Range: n/a
About: which searches the current PATH variable for an
occurrence of name. If it finds one, the path to
name is printed. Multiple names are accepted, in
which case the process is repeated for each one.
If the '-s' option is set, which will terminate
silently if the name is not found in the search
path. Normally it prints a message to that
effect.
Although which does not know about aliases or
functions as whence does, it is often more useful
in scripts or from the command line. For example,
if you know that "my_file" is in the search path,
you can say:
ll $(which -s my_file)
to print information on my_file without knowing
where it is. The example below is another pos-
sible use. In the function, which is used both to
avoid interpreting "run" recursively as a func-
tion, and to find the desired binary. A better
form of the 'run' function is included with the
default '.skshinit' file.
Example: function run {
cmd="$1"
shift
$(which -s run) $(which $cmd) $*
}
See Also: whence
_________________________________________________________________
SKsh Amiga Shell Page 108 Reference Manual
_________________________________________________________________
Name: while/do/done
Type: Keywords
Default: n/a
Usage: while expr do stmt_list done
Range: n/a
About: The statement list is executed while the expres-
sion is true (returns a zero exit status).
Example: a=1
while [ $a -le 10 ]
do
echo "a = $a"
done
See Also: for
_________________________________________________________________
SKsh Amiga Shell Page 109 Reference Manual